"""
output max parrots on road from left-up to right-down
2 3
1 4 9
3 5 9
"""

def step(data, m, n):
    if m==0 and n==0:
        return data[0][0]
    elif m==0 and n>0:
        return data[m][n] + step(data, m, n-1)
    elif m>0 and n==0:
        return data[m][n] + step(data, m-1, n)
    else:
        return data[m][n] + max(step(data, m-1, n), step(data, m, n-1))


if __name__=="__main__":
    M, N = map(int, input().split())
    data = []
    for idx in range(M):
        data.append(list(map(int, input().split())))

    result = step(data, M-1, N-1)
    print(result)